/*
*ArrayListDemo1.java
*/
package SampleCollection.SampleCollection;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author Ridhav
 * 
 */
public class ArrayListDemo1 {

	public static void main(String args[]){
	ArrayList alist=new ArrayList();
	alist.add("ridhav");
	alist.add("ridv");
	alist.add("rid");
	System.out.println("array list is " +alist);
	
	// Or we can use Iterator
	for (Iterator iter=alist.iterator(); iter.hasNext();) {
		String element=(String)iter.next();
		System.out.println("element is" +element);
	}
		// contains
		System.out.println(alist.contains("rid"));
		// to remove
		alist.remove("ridv");
		System.out.println(alist);
	
	System.out.println(alist.get(0));	
		
	//TO ARRAY
		Object[] s= alist.toArray();
		for (int i = 0; i < s.length; i++) {
			System.out.println(s[i]);
		}
	// .CLEAR METHOD TO CLEAR THE ELEMENTS
	
	
	
}
}
